﻿<%@ Page Title="Management Users" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="UserManagement.aspx.cs" Inherits="Admin_UserManagement" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
    <div>
        <telerik:RadGrid ID="uxUser" runat="server" AutoGenerateColumns="false" 
            AllowPaging="false" AllowSorting="false"
             PageSize="30" ShowStatusBar="true" 
            PagerStyle-Mode="NextPrevNumericAndAdvanced" Skin="Office2007" 
            onneeddatasource="uxUser_NeedDataSource" 
            ondeletecommand="uxUser_DeleteCommand" oninsertcommand="uxUser_InsertCommand" 
            onupdatecommand="uxUser_UpdateCommand">
             <MasterTableView DataKeyNames="UserID" CommandItemDisplay="TopAndBottom">
                <Columns>
                    <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="UserID" HeaderText="UserID" UniqueName="UserID" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" UniqueName="UserName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Address" HeaderText="Address" UniqueName="Address">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn DataField="UserRole" HeaderText="IsAdmin" UniqueName="UserRole">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridCheckBoxColumn DataField="IsActivated" HeaderText="IsActivated" UniqueName="IsActivated">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete" ConfirmDialogType="RadWindow"
                        ConfirmText="Are you sure you would like to delete this?" ConfirmTitle="Delete">
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table>
                            <tr>
                                <td>UserName : </td>
                                <td>
                                    <asp:TextBox ID="txtUserName" runat="server" Enabled='<%# (Container is GridEditFormInsertItem) ? true : false %>' Text='<%#Eval("UserName") %>'></asp:TextBox><br />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Tên UserName không được để trống" ControlToValidate="txtUserName" ForeColor="Red" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>Password : </td>
                                <td>
                                    <asp:TextBox ID="txtPassword" runat="server" Text='<%#Eval("Password") %>'></asp:TextBox><br />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Password không được để trống" ControlToValidate="txtPassword" ForeColor="Red" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>Address : </td>
                                <td>
                                    <asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine" Text='<%#Eval("Address") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>Email : </td>
                                <td>
                                    <asp:TextBox ID="txtEmail" runat="server" Text='<%#Eval("Email") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>Phone : </td>
                                <td>
                                    <asp:TextBox ID="txtPhone" runat="server" Text='<%#Eval("PhoneNumber") %>'></asp:TextBox><br />
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Số điện thoại không được để trống" ControlToValidate="txtPhone" ForeColor="Red" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>IsAdmin : </td>
                                <td>
                                    <asp:DropDownList ID="ddlIsAdmin" runat="server" AppendDataBoundItems="true" DataSource='<%# (new string[] {"True", "False"})%>' SelectedValue='<%# Eval("UserRole") %>'>
                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td>IsActivated : </td>
                                <td>
                                    <asp:DropDownList ID="ddlIsActivated" runat="server" AppendDataBoundItems="true" DataSource='<%# (new string[] {"True", "False"})%>' SelectedValue='<%# Eval("IsActivated") %>'>
                                        <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                     CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                                     &nbsp;
                                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False" CommandName="Cancel"/>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
             </MasterTableView>
        </telerik:RadGrid>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
            Width="75px">
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
                style="border: 0px;" />
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="uxUser">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="uxUser" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
    </div>
</asp:Content>